#pragma once

#include "device/Vector_dev.hpp"
#include "UnifiedMemManaged.hpp"

struct Ray : public UnifiedMemManaged
{
    // Destination = origin + t*direction
    Vector3fDev origin;
    Vector3fDev direction, direction_inv;
    double t; // transportation time,
    double t_min, t_max;

    __device__ Ray(const Vector3fDev *ori, const Vector3fDev &dir, const double _t = 0.0) : origin(*ori), direction(dir), t(_t)
    {
        direction_inv = Vector3fDev(1. / direction.x, 1. / direction.y, 1. / direction.z);
        t_min = 0.0;
        t_max = 1024000.0;
    }

    Ray(const Vector3fDev *ori, const Vector3fDev &dir, bool isFromHost, const double _t = 0.0) : origin(*ori), direction(dir), t(_t)
    {
        assert(isFromHost);
        direction_inv = Vector3fDev(1. / direction.x, 1. / direction.y, 1. / direction.z, true);
        t_min = 0.0;
        t_max = 1024000.0;
    }

    // __device__ Vector3fDev operator()(double t) const { return origin + direction * t; }
};
